package top.sjydzq.one.Controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import top.sjydzq.one.Mapper.ArticleMapper;
import top.sjydzq.one.Mapper.CategoryMapper;

@Controller
public class ListController {
    @Autowired
    private CategoryMapper categoryMapper;
    @Autowired
    private ArticleMapper articleMapper;

    @RequestMapping("/list")
    public String list(Model model, int cat) {
        model.addAttribute("cat", categoryMapper.selectById(cat));
        model.addAttribute("articles", articleMapper.selectByCatId(cat));

        return "list";
    }
}
